/**
 * 项目名：	Rumba Plan
 * 
 * 版权所有(C)，上海海鼎信息工程股份有限公司，2007，所有权利保留。
 * 
 * 文件名：	FVRumbaQt.java
 * 模块说明：	
 * 修改历史：
 * Apr 19, 2007 - zhangyanbo - 创建。
 */
package com.hd123.rumba.cartridge;

import net.sf.hibernate.HibernateException;

import com.hd123.rumba.action.qt.ViewQuery;
import com.hd123.rumba.cartridge.biz.BCartFunctionView;
import com.hd123.rumba.cartridge.entry.Entry;
import com.hd123.rumba.domain.CDomain;
import com.hd123.rumba.domain.IDomain;
import com.hd123.rumba.exception.BusinessException;
import com.hd123.rumba.gwt.entry.client.menu.CMenuItem;
import com.hd123.rumba.navigation.menu.BMenu;
import com.hd123.rumba.navigation.menu.BMenuItem;
import com.hd123.rumba.user.IUser;

/**
 * 功能视图：查询工具
 * <p>
 * 
 * 标题：查询工具<br>
 * 前缀：RBQT<br>
 * 抽象：否<br>
 * 说明：提供一般域用户使用查询工具的功能的操作界面。<br>
 * 依赖：FVRumbaSystemCommon<br>
 * 
 * @author zhangyanbo
 * 
 */
public class FVRumbaQt extends BCartFunctionView {

  public static final String FUNCV_PREFIX = "RBQT";

  @Override
  public boolean canLoadToDomain(IDomain domain) throws BusinessException, HibernateException {
    return !CDomain.VALUE_ID_ROOT.equals(domain.getCode());
  }

  @Override
  public void onLoadToDomain(IDomain domain, IUser operator) throws BusinessException,
      HibernateException, InterruptedException {
    // Do Nothing
  }

  @Override
  public void onUnloadFromDomain(IDomain domain, IUser operator) throws BusinessException,
      HibernateException, InterruptedException {
    // Do Nothing
  }

  public static final String ID_ENTRY_QUERYDEF = "queryDef";
  public static final String ID_ENTRY_QUERYTREE = "queryTree";
  public static final String ID_ENTRY_MYRESULT = "myResult";
  public static final String ID_ENTRY_ALLRESULT = "allResult";

  @Override
  protected void buildEntries() throws BusinessException {
    this.getEntries().clear();
    Entry e = null;

    e = this.appendEntry(ID_ENTRY_QUERYDEF, "查询定义");
    e.setPermission(ViewQuery.PERMISSION_ADMINDEFINITIONS);
    e.setImage("rumba/images/qt/qt_small.gif");
    e.appendLink("qt/ViewQuery?start=listDef");

    e = this.appendEntry(ID_ENTRY_QUERYTREE, "查询目录");
    e.setImage("rumba/images/qt/qt_small.gif");
    e.appendLink("qt/NavDefinitions?start=listTreeView&name=/");

    e = this.appendEntry(ID_ENTRY_MYRESULT, "我的查询结果");
    e.setPermission(ViewQuery.PERMISSION_ADMINRESULTS);
    e.setImage("rumba/images/qt/qt_small.gif");
    e.appendLink("qt/ViewQuery?start=myquerysList");

    e = this.appendEntry(ID_ENTRY_ALLRESULT, "所有查询结果");
    e.setPermission(ViewQuery.PERMISSION_ADMINRESULTS);
    e.setImage("rumba/images/qt/qt_small.gif");
    e.appendLink("qt/ViewQuery?start=allquerysList");
  }

  @Override
  protected void buildMainMenu(BMenu mainMenu) throws BusinessException {
    BMenuItem miSystem = BMenuItem.build(null, "系统", null);
    mainMenu.addItem(miSystem, null);

    BMenuItem miQuery = BMenuItem.build(null, "查询报表", CMenuItem.VALUE_ALIGN_RIGHTBOTTOM);
    miQuery.setImage("rumba/images/qt/qt_small.gif");
    mainMenu.addItem(miQuery, miSystem);
    mainMenu.addItem(BMenuItem.build(this.getEntryById(ID_ENTRY_QUERYDEF)), miQuery);
    mainMenu.addItem(BMenuItem.build(this.getEntryById(ID_ENTRY_QUERYTREE)), miQuery);
    mainMenu.addItem(BMenuItem.build(this.getEntryById(ID_ENTRY_MYRESULT)), miQuery);
    mainMenu.addItem(BMenuItem.build(this.getEntryById(ID_ENTRY_ALLRESULT)), miQuery);
  }
}
